/**
 * Created by huangxuehua on 2017/12/8.
 */
$("header>a.goBack").click(function(){
    window.history.back()
});

var toast = new auiToast(); //初始化toast事件
var xpHome = new Vue({
    el:'#app',
    data:{
        userInfo:{}//客户信息
    },
    methods: {
       getUserINfo:function(){
           if(!xpHome.userInfo,xpHome.userInfo.erwUrl ){
               toast.custom({
                   title: "未获取到用户信息",
                   html: '',
                   duration: 2000
               });
               return false;
           }
           $.ajax({
               url: nUrls.getUserErWeiMa,
               type:'post',
               success:function(data){
                   var result = eval('('+data+')');
                   if(result && result.code == 200){
                       //console.log(result)
                       xpHome.userInfo = result;
                  var qrcode = $('#qrCodeDiv').qrcode({
                           render : "canvas",
                           text:xpHome.userInfo.erwUrl,
                           height: "200",
                           width: "200",
                           background: '#ffffff',
                           foreground: '#000000',
                           src:xpHome.userInfo.wx_images
                       }).hide();
                       var canvas=qrcode.find('canvas').get(0);
                       $('#imgOne').attr('src',canvas.toDataURL('image/png'))//.hide();

                       //console.log("---  xpHome.userInfo--",  xpHome.userInfo,xpHome.userInfo.erwUrl);
                   }
               },
               error:function(){
                   console.log("没有更多商品")
               }
           });
       },
        goOnLine:function(){  //断网刷新
            nUtils.onLine();
        }
    }
});

$(function(){
    xpHome.getUserINfo()
})
